package com.codedancer.campus.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.codedancer.campus.common.core.BaseMapper;
import com.codedancer.campus.po.UpdateLogReadRecord;

public interface UpdateLogReadRecordMapper extends BaseMapper<UpdateLogReadRecord> {

    /**
     * 是否已读某个更新日志
     *
     * @param currentLoginUserUuid
     * @param uuid
     * @return
     */
    default boolean isRead(String currentLoginUserUuid, String uuid) {
        LambdaQueryWrapper<UpdateLogReadRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UpdateLogReadRecord::getUpdateLogUuid, uuid);
        lambdaQueryWrapper.eq(UpdateLogReadRecord::getUserUuid, currentLoginUserUuid);
        return selectCount(lambdaQueryWrapper) > 0;
    }
}
